package com.cuiweiyou.rootapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.cuiweiyou.middleman.PluginManager;

public class MainActivity extends AppCompatActivity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    
    // 布局中控件点击事件
    public void runPlugin(View view) {
        PluginManager.getInstance().setContext(this);
        PluginManager.getInstance().loadPluginApkFile("/sdcard/ddd.apk"); // sd卡上的插件apk。申请权限略。
        
        String launcherActivityName = PluginManager.getInstance().getPackageInfo().activities[0].name; // 插件入口
        Intent intent = new Intent(this, GhostActivity.class); // 替身
        intent.putExtra("className", launcherActivityName); // 告诉替身插件的入口
        startActivity(intent); // 启动替身
    }
}